#pragma once
#include "stdafx.h"
#include "Operator.h"
#include "QueueEntity.h"
#include "LineageSynopsis.h"
#include "RelationSynopsis.h"
#include "Operator.h"
#include "ElementIterator.h"
#include <boost/shared_ptr.hpp>
enum JoinBlockState
{
	LEFT_PLUS_BLOCK,
	LEFT_MINUS_BLOCK,
	RIGHT_PLUS_BLOCK,
	RIGHT_MINUS_BLOCK,
};
class JoinOperator: public Operator
{
private:

	boost::shared_ptr<RelationSynopsis>leftRelationSynopsis;
	boost::shared_ptr<RelationSynopsis>rightRelationSynopsis;
	boost::shared_ptr<LineageSynopsis>lineageSynopsis;
	Timestamp lastLeftTimestamp;
	Timestamp lastRightTimestamp;
	std::string leftJoinAttribute;
	std::string rightJoinAttribute;
	boost::shared_ptr<ElementIterator> leftElementIterator;
	boost::shared_ptr<ElementIterator> rightElementIterator;

	void dealWithBlock(void);
	void leftPlusBlock(void);
	void leftMinusBlock(void);
	void rightPlusBlock(void);
	void rightMinusBlock(void);
	JoinBlockState joinBlockState;
	Element blockElement;
public:
	JoinOperator(void);
	~JoinOperator(void);
	
	void execution(int executionTimes);
	void processLeftPlus (Element& leftElement);
	void processLeftMinus (Element& leftElement);
	void processRightPlus (Element& rightElement);
	void processRightMinus (Element& rightElement);
	void setLeftJoinAttribute(std::string leftJoinAttribute);
	void setRightJoinAttribute(std::string rightJoinAttribute);
};

